<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Apache Solr 与 Elasticsearch 全面对比 | 现代搜索技术分析</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .section-divider {
            position: relative;
            height: 80px;
            overflow: hidden;
        }
        .section-divider svg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
            margin-bottom: 1.5rem;
        }
        .comparison-table td {
            padding: 1.25rem;
            vertical-align: top;
            border-bottom: 1px solid #e2e8f0;
        }
        .comparison-table tr:last-child td {
            border-bottom: none;
        }
        .drop-cap:first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.8;
            margin: 0.2em 0.5rem 0 0;
            font-weight: 700;
            color: #4c51bf;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 md:px-0">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-6 leading-tight">Solr <span class="opacity-80">vs</span> Elasticsearch</h1>
                    <p class="text-xl opacity-90 mb-8">现代搜索引擎技术的深度对比与分析</p>
                    <div class="flex space-x-4">
                        <a href="#comparison" class="bg-white text-indigo-700 px-6 py-3 rounded-lg font-medium hover:bg-gray-100 transition duration-300">
                            开始探索 <i class="fas fa-arrow-down ml-2"></i>
                        </a>
                        <a href="#visualization" class="border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:text-indigo-700 transition duration-300">
                            查看图表 <i class="fas fa-chart-network ml-2"></i>
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <img src="https://cdn.pixabay.com/photo/2017/05/10/19/29/robot-2301646_1280.jpg" alt="Search Technology" class="rounded-xl shadow-2xl w-full max-w-md">
                </div>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section id="visualization" class="py-16 bg-gray-50">
        <div class="container mx-auto max-w-6xl px-4">
            <div class="text-center mb-16">
                <h2 class="text-3xl font-bold text-gray-800 mb-4">核心技术对比</h2>
                <p class="text-gray-600 max-w-2xl mx-auto">通过可视化图表快速了解 Solr 与 Elasticsearch 的核心差异</p>
            </div>
            <div class="bg-white rounded-xl shadow-md p-6 mb-8">
                <div class="mermaid">
                    graph TD
                    A[Apache Solr] -->|基于| B[Lucene]
                    C[Elasticsearch] -->|基于| B[Lucene]
                    A --> D[SolrCloud架构]
                    D --> E[依赖Zookeeper]
                    C --> F[原生分布式架构]
                    A --> G[固定节点角色]
                    C --> H[灵活节点角色]
                    A --> I[更快的索引速度]
                    C --> J[更好的并发性能]
                    A --> K[复杂查询优势]
                    C --> L[实时分析优势]
                </div>
            </div>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon bg-indigo-100 text-indigo-600">
                            <i class="fas fa-server text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800 ml-4">架构设计</h3>
                    </div>
                    <p class="text-gray-600 mb-4">Solr 依赖 Zookeeper 实现分布式管理，而 Elasticsearch 采用原生分布式架构，无需外部组件。</p>
                    <div class="bg-gray-100 p-4 rounded-lg">
                        <p class="text-sm text-gray-700 font-medium"><i class="fas fa-lightbulb text-yellow-500 mr-2"></i>选择建议：如果需要简化集群管理，Elasticsearch 可能是更好的选择。</p>
                    </div>
                </div>
                <div class="bg-white rounded-xl shadow-md p-8 card-hover">
                    <div class="flex items-center mb-6">
                        <div class="feature-icon bg-purple-100 text-purple-600">
                            <i class="fas fa-tachometer-alt text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold text-gray-800 ml-4">性能表现</h3>
                    </div>
                    <p class="text-gray-600 mb-4">Solr 在索引速度上略胜一筹，而 Elasticsearch 在高并发场景下表现更稳定。</p>
                    <div class="bg-gray-100 p-4 rounded-lg">
                        <p class="text-sm text-gray-700 font-medium"><i class="fas fa-lightbulb text-yellow-500 mr-2"></i>选择建议：根据您的具体使用场景和性能需求进行选择。</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Content Section -->
    <section id="comparison" class="py-16 bg-white">
        <div class="container mx-auto max-w-6xl px-4">
            <article class="prose prose-lg max-w-none">
                <h2 class="text-3xl font-bold text-gray-800 mb-2">1. Solr 与 Elasticsearch 的概述</h2>
                
                <h3 class="text-2xl font-semibold text-gray-800 mt-8 mb-4">1.1 Apache Solr</h3>
                <p class="drop-cap">Apache Solr 是一个基于 Lucene 的开源搜索平台，最初由 Apache 软件基金会开发。Solr 提供了丰富的功能，包括全文搜索、分面搜索、高亮显示、分布式搜索等。它广泛应用于企业级搜索解决方案中。</p>
                
                <h3 class="text-2xl font-semibold text-gray-800 mt-8 mb-4">1.2 Elasticsearch</h3>
                <p class="drop-cap">Elasticsearch 是一个分布式、可扩展的搜索和分析引擎，由 Elastic 公司开发。Elasticsearch 以其近实时搜索、强大的聚合功能和易用性著称，广泛应用于日志分析、全文搜索、实时数据分析等场景。</p>
                
                <div class="section-divider my-16">
                    <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
                        <path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25" fill="#9ca3af"></path>
                        <path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5" fill="#9ca3af"></path>
                        <path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z" fill="#9ca3af"></path>
                    </svg>
                </div>
                
                <h2 class="text-3xl font-bold text-gray-800 mb-8">2. 架构设计对比</h2>
                
                <table class="comparison-table w-full bg-white rounded-lg overflow-hidden shadow-md mb-12">
                    <tr class="bg-gray-50">
                        <td class="font-bold text-gray-800">对比维度</td>
                        <td class="font-bold text-blue-600">Apache Solr</td>
                        <td class="font-bold text-purple-600">Elasticsearch</td>
                    </tr>
                    <tr>
                        <td class="font-medium text-gray-700">分布式架构</td>
                        <td>使用 SolrCloud 实现分布式架构，依赖 Zookeeper 管理集群状态和配置</td>
                        <td>原生支持分布式架构，无需依赖外部组件，内置集群管理功能</td>
                    </tr>
                    <tr>
                        <td class="font-medium text-gray-700">数据模型</td>
                        <td>使用集合(Collection)作为数据基本单元，由多个分片(Shard)组成</td>
                        <td>使用索引(Index)作为数据基本单元，由多个分片(Shard)组成</td>
                    </tr>
                    <tr>
                        <td class="font-medium text-gray-700">节点角色</td>
                        <td>节点角色固定，分为主节点(Leader)和副本节点(Replica)</td>
                        <td>节点角色灵活，可同时承担主节点、数据节点和协调节点角色</td>
                    </tr>
                </table>
                
                <h3 class="text-2xl font-semibold text-gray-800 mt-8 mb-4">2.1 分布式架构</h3>
                <ul class="list-disc pl-6 mb-6 space-y-2">
                    <li><span class="font-medium text-blue-600">Solr</span>：Solr 使用 SolrCloud 实现分布式架构。SolrCloud 通过 Zookeeper 管理集群状态和配置，支持自动分片和副本分配。</li>
                    <li><span class="font-medium text-purple-600">Elasticsearch</span>：Elasticsearch 原生支持分布式架构，无需依赖外部组件。它通过内置的集群管理功能，自动处理分片和副本分配。</li>
                </ul>
                
                <div class="section-divider my-16">
                    <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
                        <path d="M985.66,92.83C906.67,72,823.78,31,743.84,14.19c-82.26-17.34-168.06-16.33-250.45.39-57.84,11.73-114,31.07-172,41.86A600.21,600.21,0,0,1,0,27.35V120H1200V95.8C1132.19,118.92,1055.71,111.31,985.66,92.83Z" fill="#f3f4f6"></path>
                    </svg>
                </div>
                
                <h2 class="text-3xl font-bold text-gray-800 mb-8">3. 性能对比</h2>
                
                <div class="grid md:grid-cols-3 gap-6 mb-12">
                    <div class="bg-blue-50 p-6 rounded-lg">
                        <h4 class="text-xl font-semibold text-blue-800 mb-3">索引性能</h4>
                        <p class="text-gray-700"><span class="font-medium">Solr</span> 的索引性能较强，尤其在处理大规模数据时表现优异。</p>
                        <p class="text-gray-700 mt-2"><span class="font-medium">Elasticsearch</span> 的索引性能也非常出色，尤其在近实时搜索场景下表现优异。</p>
                    </div>
                    <div class="bg-purple-50 p-6 rounded-lg">
                        <h4 class="text-xl font-semibold text-purple-800 mb-3">查询性能</h4>
                        <p class="text-gray-700"><span class="font-medium">Solr</span> 的查询性能较强，尤其在复杂查询和分面搜索场景下表现优异。</p>
                        <p class="text-gray-700 mt-2"><span class="font-medium">Elasticsearch</span> 的查询性能也非常出色，尤其在实时搜索和聚合查询场景下表现优异。</p>
                    </div>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="text-xl font-semibold text-indigo-800 mb-3">扩展性</h4>
                        <p class="text-gray-700"><span class="font-medium">Solr</span> 的扩展性较强，但依赖 Zookeeper，增加了管理复杂性。</p>
                        <p class="text-gray-700 mt-2"><span class="font-medium">Elasticsearch</span> 的扩展性非常出色，原生支持分布式架构，扩展简单灵活。</p>
                    </div>
                </div>
                
                <div class="section-divider my-16">
                    <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
                        <path d="M0,0V46.29c47.79,22.2,103.59,32.17,158,28,70.36-5.37,136.33-33.31,206.8-37.5C438.64,32.43,512.34,53.67,583,72.05c69.27,18,138.3,24.88,209.4,13.08,36.15-6,69.85-17.84,104.45-29.34C989.49,25,1113-14.29,1200,52.47V0Z" opacity=".25" fill="#9ca3af"></path>
                        <path d="M0,0V15.81C13,36.92,27.64,56.86,47.69,72.05,99.41,111.27,165,111,224.58,91.58c31.15-10.15,60.09-26.07,89.67-39.8,40.92-19,84.73-46,130.83-49.67,36.26-2.85,70.9,9.42,98.6,31.56,31.77,25.39,62.32,62,103.63,73,40.44,10.79,81.35-6.69,119.13-24.28s75.16-39,116.92-43.05c59.73-5.85,113.28,22.88,168.9,38.84,30.2,8.66,59,6.17,87.09-7.5,22.43-10.89,48-26.93,60.65-49.24V0Z" opacity=".5" fill="#9ca3af"></path>
                        <path d="M0,0V5.63C149.93,59,314.09,71.32,475.83,42.57c43-7.64,84.23-20.12,127.61-26.46,59-8.63,112.48,12.24,165.56,35.4C827.93,77.22,886,95.24,951.2,90c86.53-7,172.46-45.71,248.8-84.81V0Z" fill="#9ca3af"></path>
                    </svg>
                </div>
                
                <h2 class="text-3xl font-bold text-gray-800 mb-8">4. 易用性对比</h2>
                
                <div class="grid md:grid-cols-2 gap-8 mb-12">
                    <div>
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-blue-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-cogs text-blue-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">安装与配置</h4>
                        </div>
                        <p class="text-gray-600 pl-14"><span class="font-medium text-blue-600">Solr</span> 的安装和配置相对复杂，尤其在使用 SolrCloud 时，需要配置和管理 Zookeeper。</p>
                        <p class="text-gray-600 pl-14 mt-2"><span class="font-medium text-purple-600">Elasticsearch</span> 的安装和配置相对简单，开箱即用，无需依赖外部组件。</p>
                    </div>
                    <div>
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-purple-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-code text-purple-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">API 与工具</h4>
                        </div>
                        <p class="text-gray-600 pl-14"><span class="font-medium text-blue-600">Solr</span> 提供了丰富的 REST API 和管理界面，但在 API 设计和使用上相对复杂。</p>
                        <p class="text-gray-600 pl-14 mt-2"><span class="font-medium text-purple-600">Elasticsearch</span> 提供了简单易用的 REST API 和管理工具，API 设计更加直观和友好。</p>
                    </div>
                    <div>
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-indigo-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-users text-indigo-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">文档与社区</h4>
                        </div>
                        <p class="text-gray-600 pl-14"><span class="font-medium text-blue-600">Solr</span> 的文档较为全面，但社区活跃度相对较低，获取支持和解决问题的速度较慢。</p>
                        <p class="text-gray-600 pl-14 mt-2"><span class="font-medium text-purple-600">Elasticsearch</span> 的文档非常全面，社区活跃度较高，获取支持和解决问题的速度较快。</p>
                    </div>
                    <div>
                        <div class="flex items-center mb-4">
                            <div class="w-10 h-10 bg-green-100 rounded-full flex items-center justify-center mr-4">
                                <i class="fas fa-puzzle-piece text-green-600"></i>
                            </div>
                            <h4 class="text-xl font-semibold text-gray-800">插件与扩展</h4>
                        </div>
                        <p class="text-gray-600 pl-14"><span class="font-medium text-blue-600">Solr</span> 插件生态系统较为成熟，但扩展性相对有限。</p>
                        <p class="text-gray-600 pl-14 mt-2"><span class="font-medium text-purple-600">Elasticsearch</span> 插件生态系统非常活跃，扩展性非常强。</p>
                    </div>
                </div>
                
                <div class="section-divider my-16">
                    <svg viewBox="0 0 1200 120" preserveAspectRatio="none">
                        <path d="M985.66,92.83C906.67,72,823.78,31,743.84,14.19c-82.26-17.34-168.06-16.33-250.45.39-57.84,11.73-114,31.07-172,41.86A600.21,600.21,0,0,1,0,27.35V120H1200V95.8C1132.19,118.92,1055.71,111.31,985.66,92.83Z" fill="#f3f4f6"></path>
                    </svg>
                </div>
                
                <h2 class="text-3xl font-bold text-gray-800 mb-8">5. 实际项目中的应用</h2>
                
                <div class="grid md:grid-cols-3 gap-6 mb-12">
                    <div class="bg-white rounded-lg shadow-md overflow-hidden border border-gray-200 card-hover">
                        <div class="bg-blue-600 p-4 text-white">
                            <h4 class="text-xl font-semibold">ts-search 项目</h4>
                            <p class="text-blue-100">商品搜索服务</p>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-700 mb-4">使用 Solr 实现了全文搜索功能，通过分面搜索和高亮显示功能提供高效的商品搜索服务。</p>
                            <div class="flex items-center text-sm text-blue-600">
                                <i class="fas fa-check-circle mr-2"></i>
                                <span>稳定性与成熟度是关键因素</span>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-lg shadow-md overflow-hidden border border-gray-200 card-hover">
                        <div class="bg-purple-600 p-4 text-white">
                            <h4 class="text-xl font-semibold">ts-log 项目</h4>
                            <p class="text-purple-100">日志分析系统</p>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-700 mb-4">使用 Elasticsearch 存储和分析日志数据，通过近实时搜索和聚合功能快速定位问题。</p>
                            <div class="flex items-center text-sm text-purple-600">
                                <i class="fas fa-check-circle mr-2"></i>
                                <span>易用性与扩展性是关键因素</span>
                            </div>
                        </div>
                    </div>
                    <div class="bg-white rounded-lg shadow-md overflow-hidden border border-gray-200 card-hover">
                        <div class="bg-indigo-600 p-4 text-white">
                            <h4 class="text-xl font-semibold">ts-analytics 项目</h4>
                            <p class="text-indigo-100">用户行为分析</p>
                        </div>
                        <div class="p-6">
                            <p class="text-gray-700 mb-4">使用 Elasticsearch 分析用户行为数据，通过聚合操作和 Kibana 生成复杂的统计报表。</p>
                            <div class="flex items-center text-sm text-indigo-600">
                                <i class="fas fa-check-circle mr-2"></i>
                                <span>生态系统与可视化是关键因素</span>
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="bg-yellow-50 border-l-4 border-yellow-400 p-6 mb-12">
                    <div class="flex">
                        <div class="flex-shrink-0">
                            <i class="fas fa-lightbulb text-yellow-500 text-2xl"></i>
                        </div>
                        <div class="ml-4">
                            <h4 class="text-lg font-semibold text-gray-800">选择建议</h4>
                            <p class="text-gray-700 mt-2">如果您需要企业级搜索解决方案，Solr 可能更适合；如果您需要实时数据分析或日志分析，Elasticsearch 可能是更好的选择。考虑您的具体需求、团队技能和长期维护成本。</p>
                        </div>
                    </div>
                </div>
            </article>
        </div>
    </section>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12 px-4">
        <div class="container mx-auto max-w-6xl">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-6 md:mb-0">
                    <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索技术的无限可能</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-gray-300 hover:text-white transition duration-300">
                        <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                <p>© 2023 技术小馆. 保留所有权利.</p>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: false,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>